<?php

include "includes/connection.php";
include "includes/article.php";

$article = new Article;

if (isset($_GET['id'])){
    // dispaly article
    $id = $_GET["id"];
    $date = $article->fetch_data($id);

    // print_r($date);
?>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CMS</title>
    <link rel="stylesheet" href="assets/style.css" media="all">
</head>
    <div class="container">
        <a id="logo" href="index.php">CMS</a>
        
        <h4><?php echo $date["article_title"]; ?>
        - <small>posted <?php echo date("l jS", $date["article_timestamp"]); ?></small>
        </h4>    
    
        <p><?php echo $date["article_content"]; ?></p>

        <a href="index.php">&larr; Back</a>
    </div>
<body>
    
</body>
</html>

<?php
} else {
    header("Location: index.php");
    exit();
}

?>

